<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Api\AuthController;
use App\Api\UserController;
use App\Api\RecordController;
use App\Api\LogController;
use App\Api\UploadController;
use App\Api\DepartmentController;
use App\Api\DashboardController;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

//登录
Route::post('auth/login', [AuthController::class, 'login']);
Route::group(['middleware' => ['auth:sanctum']], function () {
    Route::post("user/logout", [AuthController::class, 'logout']);
    Route::get("user/current", [UserController::class, 'current']);
    Route::put("user/password", [UserController::class, 'updatePassword']);
    Route::get("user/{user}/resetPassword", [UserController::class, 'resetPassword']);

    Route::get("user/records",[UserController::class, "records"]);
//    用户管理
    Route::apiResource("user",UserController::class);

//record业务
    Route::get("record/weekrank",[RecordController::class, "weekrank"]);
    Route::get("record/monthrank",[RecordController::class, "monthrank"]);
    Route::get("record/dayrank",[RecordController::class, "dayrank"]);
    Route::post("record/export",[RecordController::class, "export"]);
    Route::post("record/check",[RecordController::class, "check"]);
    Route::get("record/trashed",[RecordController::class, "trashed"]);
    Route::apiResource("record",RecordController::class);

//    日志
    Route::get("log/export",[LogController::class, "export"]);
    Route::apiResource("log",LogController::class);

//    图片上传
    Route::post('upload', [UploadController::class, 'upload']);

//    部门
    Route::get("department/{department}/users",[DepartmentController::class, "users"]);
    Route::post("department/{department}/bindManager",[DepartmentController::class, "bindManager"]);
    Route::post("department/{department}/unBindManager",[DepartmentController::class, "unBindManager"]);
    Route::apiResource("department",DepartmentController::class);

//    日志管理
    Route::get("log/export",[LogController::class, "export"]);
    Route::post("log/search",[LogController::class,'search']);
    Route::get("log",[LogController::class,'index']);

//    业务总览
    Route::get("dashboard",[DashboardController::class,'index']);
});
